home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Documents / JAVA Programming / examples / 14 / localURL.java < prev    next >
Encoding:
Java Source  |  2000-09-08  |  817 b   |  26 lines

  1. import java.net.*;
  2. import java.io.*;
  3. class localURL {
  4. public static void main(String args[]) throws Exception {
  5. int c;
  6. URL hp = new URL("http", "127. 0. 0.1", 80, "/");
  7. URLConnection hpCon = hp.openConnection();
  8. System.out.println("Date: " + hpCon.getDate());
  9. System.out.println("Type: " + hpCon.getContentType());
  10. System.out.println("Exp: " + hpCon.getExpiration());
  11. System.out.println( "Last M: " + hpCon.getLastModified());
  12. System.out.println("Length: " + hpCon.getContentLength());
  13. if (hpCon.getContentLength() > 0) {
  14. System.out.println("=== Content ===");
  15. InputStream input = hpCon.getInputStream();
  16. int i=hpCon.getContentLength();
  17. while (((c = input. read()) != -1) && (--i > 0)) {
  18. System.out.print((char) c);
  19. }
  20. input.close();
  21. }
  22. else {
  23. System.out.println("No Content Available");
  24. }
  25. } }
  26.